Ex006, Memo and Main menu


Memo component is a multi-line simple text, you can enter text, edit, load text
files into memo, and save it's contents in a text file.

Exercise 006: Menu and Main menu:

1. Drop a Memo from Standard page.
2. Set memo's
Align property to alClient.
3. Clear
lines property ( Clear Memo1 line ).
4. Drop a
MainMenu from Standard page.
5. Double click on
MainMenu1.
6. Press
F11 and write &File at caption.
7. Click new menu item below File, write
&Open in it's caption.
8. Below Open item add
Save As, -, Exit  respectively.
9. Beside File add new popup menu
'Fo&nt', at the right of file popup menu.
10. In
Font menu add Small, Large respectively.
11. Name
Small item 'mnSmall', Name Large item 'mnLarge'.
12. Select
True in RadioItem property for Small and Large menu items.
13. Select
True in Checked property only for Small item.
14. Drop
OpenDialog, SaveDialog from Dialogs page.
15. Click or Double-click on
Open menu item and write this code:

 if OpenDialog1.Execute then
  Memo1.Lines.LoadFromFile(
    OpenDialog1.FileName);

16. Click on Save As menu item and write:

if SaveDialog1.Execute then
  Memo1.Lines.SaveToFile(
    SaveDialog1.FileName);

17. At Exit event write:

 Close;

18. At Small event write:

 mnSmall.Checked:= True;
Memo1.Font.Size:= 8;

19. At Large event write:

 mnLarge.Checked:= True;
Memo1.Font.Size:= 14;

20. Run the program and test it.



See also:

OpenDialog